package com.origin.ebuy.forg.web.controller.user;

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSONArray;
import com.origin.ebuy.bargd.service.user.IUserService;
import com.origin.ebuy.bargd.service.user.impl.UserServiceImpl;
import com.origin.ebuy.forg.web.BaseServlet;

/**
 * Servlet implementation class UserListServlet
 */
public class UserListServlet extends BaseServlet {
	
	private static final long serialVersionUID = 1L;
       
	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		super.doPost(request,response);
		IUserService service = new UserServiceImpl();
		try {
			JSONArray array = service.queryAllUser();
			request.setAttribute("list",array);
			request.getRequestDispatcher("userlist.jsp")
			.forward(request, response);
		} catch (SQLException e) {
			e.printStackTrace();
			request.setAttribute("list","");
			request.getRequestDispatcher("userlist.jsp")
			.forward(request, response);
		}
	}

}
